﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using gnu.trove.map.hash;
using lineage2.commons.util;

namespace Game.templates.npc
{
    public class RandomActions
    {
	    private TIntObjectHashMap _actions;
	    private bool _randomOrder;

	    public RandomActions(bool randomOrder)
	    {
		    _actions = new TIntObjectHashMap();
		    _randomOrder = randomOrder;
	    }

	    public void addAction(Action action)
	    {
		    _actions.put(action.getId(), action);
	    }

	    public Action getAction(int id)
	    {
		    if (_randomOrder)
		    {
			    var actionsArr = (Action[])_actions.values(new Action[_actions.size()]);
			    return actionsArr[Rnd.get(actionsArr.Length)];
		    }
		    return (Action)_actions.get(id);
	    }

	    public int getActionsCount()
	    {
		    return _actions.size();
	    }

	    public class Action
	    {
		    private int _id;
		    private NpcString _phrase;
		    private int _socialActionId;
		    private int _delay;

		    public Action(int id, NpcString phrase, int socialActionId, int delay)
		    {
			    _id = id;
			    _phrase = phrase;
			    _socialActionId = socialActionId;
			    _delay = delay;
		    }

		    public int getId()
		    {
			    return _id;
		    }

		    public NpcString getPhrase()
		    {
			    return _phrase;
		    }

		    public int getSocialActionId()
		    {
			    return _socialActionId;
		    }

		    public int getDelay()
		    {
			    return _delay;
		    }
	    }
    }
}
